home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
10,000 Great Games
/
10,000 Great Games.iso
/
Product
/
66
/
data1.cab
/
Source_Files
/
Src
/
GameObj.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-16
|
3KB
|
141 lines
#include "stdafx.h"
cGameObject::cGameObject(cProperties *_orig)
: cMovable(_orig)
{
explode = FALSE;
waypoints = 0;
editable = 0;
influenced_by_black_hole = orig->params->get_bool("*INFLUENCED_BY_BLACK_HOLE", FALSE);
influenced_by_catapult = orig->params->get_bool("*INFLUENCED_BY_CATAPULT", FALSE);
influenced_by_inpenetrable = orig->params->get_bool("*INFLUENCED_BY_INPENETRABLE", FALSE);
fall_through_inpenetrable = orig->params->get_bool("*FALL_THROUGH_INPENETRABLE", TRUE);
score_value = orig->params->get_int("*SCORE_VALUE", 0);
}
cGameObject::~cGameObject()
{
waypoints->delete_list();
}
int cGameObject::control()
{
cMovable::control();
return !explode;
}
int cGameObject::in_water()
{
if (y < surface->start)
{
new cEffect (x, surface->start, orig, "SPLASH", TRUE);
return TRUE;
}
return FALSE;
}
void cGameObject::load(cParse *list)
{
// Get waypoints
list->get_spots("WAYPOINT", &waypoints);
// Correct waypoints if pasting
int offset = load_y_offset(surface);
if (offset)
for (cSpot *w = waypoints; w != 0; w = (cSpot *)w->next)
w->y += offset;
}
void cGameObject::save()
{
ASSERT(orig != 0);
// Write basic information
save_level_string("TYPE", orig->type);
save_level_string("NAME", orig->name);
save_level_int("X", x);
save_level_int("Y", y);
// Write waypoints
for (cSpot *w = waypoints; w != 0; w = (cSpot *)w->next)
save_level_spot("WAYPOINT", w);
}
void cGameObject::update_list()
{
// Check if possible lists are known for this object
if (orig == 0 || orig->objtype == 0)
return;
// Get list that object is currently in
cGameObject **before = (cGameObject **)get_list(), **after;
ASSERT (before != 0);
// Check in which list it should appear
if (above_screen() && (!stay_in_onscreen_list() || end_game))
{
// Check if we have to move this object in the abovescreen list
after = orig->objtype->abovescreen;
if (before != after)
relink((cList **)after);
// Above screen list is sorted on y2
sort_y2();
}
else if (below_screen())
{
// Check if we have to move this object in the belowscreen list
after = orig->objtype->belowscreen;
if (before != after)
relink((cList **)after);
// Below screen list is reversely sorted on y1
rsort_y1();
}
else
{
// Check if we have to move this object in the onscreen list
after = orig->objtype->onscreen;
if (before != after)
relink((cList **)after);
}
}
void cGameObject::create_editables(int select)
{
new cEditableGameObject(this, select);
}
void cGameObject::make_trail()
{
if (!low_detail_level && !made_trail)
{
new cEffect (x, y, orig, "TRAIL");
made_trail = orig->sequence_exists("TRAIL")? sec / 10 + rnd(sec / 4) : NEVER;
}
}